<template>
  <el-dialog
    v-model="dialogVisible"
    width="35%"
    style="
      background: #222222;
      border-radius: 9px;
      border: 1px solid rgba(255, 255, 255, 0.5);
      padding: 0;
    "
    :modal="false"
  >
    <template #header>
      <div class="title">直播收益</div>
    </template>
    <template #default>
      <div class="dialog-content">
        <div class="line"></div>
        <div class="income">
          <div style="font-size: 48px; display: flex; align-items: flex-end">
            <span>22,240</span>
            <span class="icon"></span>
          </div>
          <span style="font-size: 14px; padding: 10px 0 30px">总收益</span>
        </div>
        <div class="income-type">
          <div v-for="i in 4" class="income-type-item">
            <span style="font-size: 14px">礼物</span>
            <div class="m-t-12" style="display: flex; align-items: center">
              <span style="font-size: 18px">5,400</span>
              <span class="icon"></span>
            </div>
          </div>
        </div>
        <span class="m-t-22" style="font-size: 11px">
          分成：送礼给麦上的观众收到的分成
          <span style="color: #fd345d; cursor: default" @click="setRatio">{{ ratio }}</span>
        </span>
        <div class="footer">
          <!-- 主播 -->
          <div class="item">
            <img
              style="width: 36px; height: 36px; margin-bottom: 3px"
              src="@/assets/register/default_avator.png"
            />
            <span class="anchor-name">小包子12138</span>
            <div class="anchor">主播</div>
          </div>
          <div class="separator"></div>
          <!-- 排麦list -->
          <div v-for="i in 3" class="item">
            <img
              style="width: 36px; height: 36px; margin-bottom: 3px"
              src="@/assets/register/default_avator.png"
            />
            <span class="anchor-name">小包子</span>
          </div>
        </div>
      </div>
    </template>
  </el-dialog>
  <IncomeRatioSetting ref="incomeRatioSettingRef" />
</template>
<script lang="ts" setup>
import { ref } from "vue";
import IncomeRatioSetting from "./IncomeRatioSetting.vue";

const dialogVisible = ref(false);
const ratio = ref("30%");
const incomeRatioSettingRef = ref();
// 显示
const show = () => {
  dialogVisible.value = true;
};
// 关闭
const close = () => {
  dialogVisible.value = false;
};

const setRatio = () => {
  incomeRatioSettingRef.value.show(ratio);
};

defineExpose({ show, close });
</script>
<style lang="scss" scoped>
.title {
  padding: 24px 32px;
  font-size: 16px;
}
.dialog-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #fff;
  .line {
    width: 100%;
    height: 1px;
    background-color: #e7e7e7;
    margin-bottom: 48px;
  }
  .income {
    display: flex;
    flex-direction: column;
    align-items: center;
    .icon {
      width: 26px;
      height: 26px;
      border-radius: 50%;
      background-color: purple;
      margin-bottom: 10px;
    }
  }
  .income-type {
    display: flex;
    gap: 32px;
    padding: 0 32px;
    &-item {
      width: 144px;
      padding: 22px 0;
      background: #2f2f2f;
      border-radius: 4px;
      display: flex;
      flex-direction: column;
      align-items: center;
      .icon {
        width: 16px;
        height: 16px;
        border-radius: 50%;
        background-color: purple;
      }
    }
  }
  .footer {
    margin: 30px 0 22px;
    display: flex;
    gap: 20px;
    align-items: center;
    .item {
      display: flex;
      flex-direction: column;
      align-items: center;
      font-size: 12px;
      position: relative;
      .anchor-name {
        width: 60px;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
        text-align: center;
      }
      .anchor {
        width: 30px;
        height: 12px;
        line-height: 12px;
        text-align: center;
        position: absolute;
        top: -10px;
        background: linear-gradient(270deg, #f59343 0%, #f80759 100%);
        border-radius: 57px 57px 57px 57px;
        font-size: 8px;
      }
    }
    .separator {
      height: 17px;
      width: 2px;
      background: #8a8a8a;
    }
  }
}
</style>
